import { createReducer } from 'redux-immutablejs'
import Immutable from 'immutable'

import {
	REQUEST_ARTICLE,
	RECEIVE_ARTICLE
} from './actions'

const initialState = Immutable.fromJS({
	detail: {},
	isArticleFetching: true
})

export default createReducer(initialState, {
	[REQUEST_ARTICLE]: (state, action) => state.merge({
		isArticleFetching: true
	}),
	[RECEIVE_ARTICLE]: (state, action) => state.merge({
	  isArticleFetching:false,
	  detail: action.article
	})
})